// 自己封装的axios
import axios from "./axios";

// 获取菜单列表(树形结构)
export const getMenuList = () => {
  return axios.get('/menulist?istree=1')
}

// 删除菜单
export const delMenu = (id) => {
  return axios.post('/menudelete', {id: id})
}

// 编辑菜单
export const editMenu = (data) => {
  // data一定要是对象
  return axios.post('/menuedit', data)
}

// ==================

// 角色列表
export const getRoleList = () => {
  return axios.get('/rolelist')
}

// 角色添加
export const roleAdd = (data) => {
  return axios.post('/roleadd', data)
}

// 角色修改
export const roleEdit = (data) => {
  return axios.post('/roleedit', data)
}

// ======================

// 管理员添加
export const adminAdd = (data) => {
  return axios.post('/useradd', data)
}

// 获取管理员总数
export const getUserConut = () => {
  return axios.get('/usercount')
}

// 管理员列表
export const getUserList = (data) => {
  return axios.get('/userlist', {params: data})
  // return axios.get('/userlist?page='+data.page+'&size='+data.size)
}

// 商品分类树形列表
export const getCateListTree = () => {
  return axios.get('/catelist', {params: {istree: 1}})
}
// 一级分类下的二级数据
export const getCateListById = (id) => {
  return axios.get('/catelist', {params: {pid: id}})
}

// 商品分类列表
export const getCateList = () => {
  return axios.get('/catelist')
}

// 分类添加
export const cateAdd = (data) => {
  return axios.post('/cateadd', data)
}

// 分类修改
export const cateEdit = (data) => {
  return axios.post('/cateedit', data)
}

// 获取规格列表
export const getSpecsList = () => {
  return axios.get('/specslist', {params: {page: 1, size: 99}})
}

// 获取规格信息
export const getSpecsInfo = (id) => {
  return axios.get('/specsinfo', {params: {id: id}})
}

// 规格添加
export const cateSpecs = (data) => {
  return axios.post('/specsadd', data)
}

// 获取商品总数
export const getGoodsConut = () => {
  return axios.get('/goodscount')
}

// 商品列表
export const getGoodsList = (data) => {
  return axios.get('/goodslist', {params: data})
}

// 后台管理员登录
export const login = (data) => {
  return axios.post('/userlogin', data)
}
